<template>
	
	<view style="text-align: center;">
		<view style="margin-top: 100px;">
			
			<img :src="iconFilePath" @click="updateImage()" mode="aspectFill" />
			
		</view>
		<view class="">
			<button @click="DownImg()">下载图片</button>
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				iconFilePath:"/static/city5.jpg"
			}
		},
		methods: {
			updateImage(){
				uni.chooseImage({
					count:1,
					sourceType:['album'],
					success: (res) => {
						console.log(res.tempFilePaths[0]);
						this.iconFilePath = res.tempFilePaths[0]
					}
				})
			},
			DownImg(){
				const imagetask = uni.downloadFile({
					url:this.iconFilePath,
					success: () => {
						console.log('下载成功');
						
					},
					fail: () => {
						console.log('下载失败');
					}
				});
				
				imagetask.onProgressUpdate((res)=>{
					console.log('下载进度',res.progress+"%");
				})
			}
		}
	}
</script>

<style>

</style>
